using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.WebTesting;
using WebAndLoadTestPlugins;

namespace PluginTests
{
    /// <summary>
    /// Summary description for ExtractInputFieldTest
    /// </summary>
    [TestClass]
    public class ExtractInputFieldTest
    {
        public ExtractInputFieldTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext) 
        {
            PageManager.Initialize(testContext);
        }

        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestExtractInputValue()
        {
            CustomExtractInput extractInputRule = new CustomExtractInput();
            extractInputRule.Name = "UserName";
            extractInputRule.ContextParameterName = "UserName";

            HtmlDocument doc;
            PageManager.Instance.LoadPage("SimpleForm.htm", out doc);

            //String content = "<html><input type=\"text\" Name=\"UserName\" Value=\"value\"></html>";
            //HtmlDocument doc = new HtmlDocument(new System.Uri("http://localhost", true), content);
            string value;
            extractInputRule.ExtractValue(doc, out value);
            Assert.AreEqual(value, "Fred");

        }
    }
}
